{% extends 'layout.html' %}
{% block content %}
    <div class="container-fluid">
        <div class="panel panel-default table-responsive">
            <div class="panel-heading">
                <span class="glyphicon glyphicon-list" aria-hidden="true"></span>
                预算/实绩查询
                <!-- Multiple Select -->
                <div class="input-group" style="float: right;">
                    {{ select }}
                    <span  aria-hidden="true"> </span>
                    <a href="{% url 'export-excel-budget' %}?start_recno={{ start_recno }}&end_recno={{ end_recno }}" class="btn btn-sm btn-primary" style="margin-top: -6px">导出 Excel</a>
                </div>
            </div>

            <table class="table text-nowrap table-striped table-bordered table-hover">
                <thead>
                <tr style="background-color: #5B9BD5;color: white">
                    <th>序号</th>
                    <th>年月</th>
                    <th>作业区编码</th>
                    <th>费用分类</th>
                    <th>预算</th>
                    <th>实绩</th>
                    <th>产线名称</th>
                </tr>
                </thead>
                <tbody>

                {% for row in data_list %}
                    <tr>
                        <td>{{ row.序号 }}</td>
                        <td>{{ row.年月 }}</td>
                        <td>{{ row.作业区编码 }}</td>
                        <td>{{ row.费用分类 }}</td>
                        <td style="text-align: right">
                            {% if row.预算 == 0  or row.预算 == None %}
                                -
                            {% else %}
                                {{ row.预算 }}
                            {% endif %}</td>
                        <td style="text-align: right">
                            {% if row.实绩 == 0  or row.实绩 == None %}
                                -
                            {% else %}
                                {{ row.实绩 }}
                            {% endif %}</td>
                        <td>{{ row.产线名称 }}</td>
                    </tr>
                {% endfor %}
                <tr style="background-color: yellow">
                    <td></td>
                    <td></td>
                    <td>合计</td>
                    <td>{{ sum_row.费用分类__count }}</td>
                    <td style="text-align: right">{{ sum_row.预算__sum }}</td>
                    <td style="text-align: right">{{ sum_row.实绩__sum }}</td>
                    <td></td>
                </tr>
                </tbody>
            </table>

            <nav aria-label="Page navigation">
                <ul class="pagination">
                    {{ page_string }}
                </ul>
            </nav>
        </div>
    </div>

{% endblock %}

{% block js %}
    <script type="text/javascript">
        $(function () {
            $('#col_select').multipleSelect({
                onClose: function () {
                    $.ajax({
                        url: '/budget/list/?f=' + $('#col_select').multipleSelect('getSelects'),
                        type: 'GET',
                        success: function (res) {
                            if (!res.status)
                                alert(res.errors);

                            // location.reload();
                        }
                    });
                }
            });
        })

    </script>
{% endblock %}